package com.jeect.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
//@MapperScan(basePackages = "com.jeect.mapper")
public class UserController {


    @Autowired
    private HttpServletRequest request;

    @GetMapping("/user/{str}")
    public Object hi(@PathVariable String str){
        request.getSession().setAttribute("id",str);

        return "已经设置"+str+"到Session中";
    }
    @GetMapping("/user/get/")
    public Object get(){
        String id = (String)request.getSession().getAttribute("id");

        return "用户ID为:"+id;
    }

//    @GetMapping("/user/{username}")
//    public User login(@PathVariable String username) {
//        User user = this.userService.getUserByUserName(username);
//        return user;
//    }
}
